package com.cynteka.cyfoman.ui.collection.factory;

import com.cynteka.cyfoman.ui.GridWidgetFactory;
import org.apache.commons.chain.Catalog;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;

/**
 * User: Sergey
 * Date: 09.08.11
 * Time: 23:34
 */
public abstract class AbstractCollectionWidgetFactory extends GridWidgetFactory implements BeanFactoryAware {
    public static final String SELECTION_CHANGED_CMD = "selectionChanged";
    public static final String SELECTED_OBJECTS_PARAM = "selectedObjects";
    public static final String COLLECTION_ID_PARAM = "collectionId";

    private Catalog catalog;
    private BeanFactory beanFactory;


    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }

    protected void initCatalog() {
        if(catalog == null) {
            catalog = (Catalog) beanFactory.getBean(Catalog.CATALOG_KEY);
        }
    }

    protected Catalog getCatalog() {
        return catalog;
    }
}
